<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/common/head.jsp"%>
<div class="right">

	<div>
		<a href="${pageContext.request.contextPath}/frame">
			<img src="${pageContext.request.contextPath}/statics/images/home.png" alt="首页"/>
		</a>
		<h3 style="display: inline-block">当前位置：</h3>用户管理页面
	</div>
	<div>
		<form action="${pageContext.request.contextPath }/user/queryUser" method="post" style="line-height: 100px">
			<table id="search" style="display: inline-block;height: 100px">
				<tr>
					<td style="margin:20px;padding: 20px">
						用户名：<input type="text" name="realName" value="${realName}"/>
					</td>
					<td style="margin:20px;padding: 20px">
						角色：
						<select name="roleId">
							<option value="0" ${roleId == 0 ? "selected" : ""}>--全部--</option>
							<c:forEach items="${roleList}" var="role">
								<option value="${role.id}" ${roleId == role.id ? "selected" : ""}>${role.roleName}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
			</table>
			<div style="height: 100px;display: inline-block">

				<input type="submit" value="查询" style="width: 80px;margin-left: 145px;text-align: center;"/>
				<input id="add" type="button" value="添加" style="width: 80px;margin-left: 145px;text-align: center;"/>
			</div>
		</form>
		<div>
			<table style="width: 100%;text-align: center" border="1">
				<tr>
					<th>账号</th>
					<th>真实姓名</th>
					<th>角色</th>
					<th>性别</th>
					<th>年龄</th>
					<th>电话</th>
					<th>操作</th>
				</tr>
				<c:forEach var="sysUser" items="${queryUserList }">
					<tr>
						<td>${sysUser.account }</td>
						<td>${sysUser.realName }</td>
						<td>${sysUser.roleIdName}</td>
						<td>${sysUser.sex == 1 ? "男" : "女"}</td>
						<td>${sysUser.age }</td>
						<td>${sysUser.phone }</td>
						<td>
							<a id="info" href="${pageContext.request.contextPath }/user/info?id=${sysUser.id}">
								<img src="${pageContext.request.contextPath}/statics/images/view.png" alt="详情"/>
							</a>
							<a id="update" href="${pageContext.request.contextPath }/user/toUpdate?id=${sysUser.id}">
								<img src="${pageContext.request.contextPath}/statics/images/xiugai.png" alt="修改"/>
							</a>
							<a id="delete" href="${pageContext.request.contextPath }/user/delete?id=${sysUser.id}">
								<img src="${pageContext.request.contextPath}/statics/images/del.png" alt="删除"/>
							</a>
						</td>
					</tr>
				</c:forEach>
			</table>
		</div>
		<div class="page-bar">
			<ul class="page-num-ul">
				<li>共${count}条记录</li>
				<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
				<c:if test="${pageIndex > 1}"><li><a href="${pageContext.request.contextPath }/user/queryUser?pageIndex=${pageIndex - 1}&realName=${realName}&roleId=${roleId}">上一页</a></li></c:if>
				<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
				<li>${pageIndex}/${pageCount}页</li>
				<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
				<c:if test="${pageIndex < pageCount}"><li><a href="${pageContext.request.contextPath }/user/queryUser?pageIndex=${pageIndex + 1}&realName=${realName}&roleId=${roleId}">下一页</a></li></c:if>
			</ul>
			<div class="page-go-form">
				<form action="${pageContext.request.contextPath }/user/queryUser" method="post">
					<input style="display: none" name="realName" value="${realName}"/>
					<input style="display: none" name="roleId" value="${roleId}"/>
					<label>
						跳转至<input type="text" name="pageIndex"/>页
					</label>
					<button type="submit">Go</button>
				</form>
			</div>
		</div>
	</div>
</div>
<script src="${pageContext.request.contextPath}/statics/js/jquery-1.8.3.min.js"></script>
<script>
	$(document).ready(function (){
		$("#add").click(function (){
			location.href="${pageContext.request.contextPath }/user/toAdd";
		})
	})
</script>
</section>
<%@include file="/WEB-INF/jsp/common/foot.jsp" %>